package com.guarantee.server.common.utils.yky;//package com.platform.youkeyun.util;
//
//import cn.hutool.core.codec.Base64;
//import org.bouncycastle.asn1.ASN1EncodableVector;
//import org.bouncycastle.asn1.ASN1Integer;
//import org.bouncycastle.asn1.DERSequence;
//import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
//import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
//import org.bouncycastle.crypto.params.ECPublicKeyParameters;
//import org.bouncycastle.math.ec.ECPoint;
//import org.bouncycastle.util.encoders.Hex;
//
//import java.io.IOException;
//import java.io.UnsupportedEncodingException;
//import java.math.BigInteger;
//
//
///*********************************************************
// * 文件名称：YLSm2Utils.java
// * 系统名称：交易银行系统V2.0
// * 模块名称：com.hundsun.tbsp.adapter.out.server.service.utils.sm2
// * 功能说明：
// * 开发人员：jinyh28985
// * 开发时间：2020/8/27 10:56
// * 修改记录：程序版本  修改日期  修改人员  修改单号  修改说明
// *********************************************************/
//public class QzSm2Utils {
//    //加密
//    public static String encrypt(String publicKey,String data)  {
//        byte [] sourceData = new byte[0];
//        try {
//            sourceData = data.getBytes("UTF-8");
//        } catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
//
//        }
//        String sts = SM2EnDecryption.encrypt(Util.hexStringToBytes(publicKey), sourceData);
//        return sts;
//    }
//    //解密
//    public static String decrypt(String privatekey,String strEncrypt)  {
//        String strD = null;
//        try {
//            strD = new String(SM2EnDecryption.decrypt(Util.hexStringToBytes(privatekey), Util.hexToByte(strEncrypt)));
//        } catch (IOException e) {
//            e.printStackTrace();
//            return null;
//        }
//        return strD;
//    }
//    //解密 指定编码的
//    public static String decrypt(String privatekey,String strEncrypt,String charsetName)  {
//        String strD = null;
//        try {
//            strD = new String(SM2EnDecryption.decrypt(Util.hexStringToBytes(privatekey), Util.hexToByte(strEncrypt)),charsetName);
//        } catch (IOException e) {
//            e.printStackTrace();
//            return null;
//        }
//        return strD;
//    }
//    //加签
//    public static String sign(String privatekey,String data)  {
//        byte [] sourceData = new byte[0];
//        try {
//            sourceData = data.getBytes("UTF-8");
//        } catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
//        }
//        //加签
//        SM2SignVO sign = null;
//        try {
//            sign = SM2VerifySign.Sign2SM2(Util.hexStringToBytes(privatekey), sourceData);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        //获取加签结果
//        String signStr = sign.getSign_r()+sign.getSign_s();
//        while (signStr.length() != 128){
//            try {
//                sign = SM2VerifySign.Sign2SM2(Util.hexStringToBytes(privatekey), sourceData);
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//            signStr = sign.getSign_r()+sign.getSign_s();
//        }
//        return signStr;
//    }
//    //验签
//    public static boolean chickSign(String publicKey,String signStr,String signData){
//        byte[] rb  = Hex.decode(signStr.substring(0,64));
//        BigInteger r = new BigInteger(1, rb);
//        byte[] br  = Hex.decode(signStr.substring(64));
//        BigInteger s = new BigInteger(1, br);
//        ASN1Integer d_r = new ASN1Integer(r);
//        ASN1Integer d_s = new ASN1Integer(s);
//        ASN1EncodableVector v2 = new ASN1EncodableVector();
//        v2.add(d_r);
//        v2.add(d_s);
//        DERSequence signtest = new DERSequence(v2);
//        String result = null;
//        try {
//            result = Util4Hex.bytesToHexString(signtest.getEncoded());
//        } catch (IOException e) {
//            e.printStackTrace();
//            return false;
//        }
//        SM2SignVO sm2SignVOtest = new SM2SignVO();
//        sm2SignVOtest.setSm2_type("sign");
//        sm2SignVOtest.setSm2_sign(result);
//        //验签
//        SM2SignVO verifys = null;
//        try {
//            verifys = SM2VerifySign.VerifySignSM2(Util.hexStringToBytes(publicKey),signData.getBytes("UTF-8"), Util4Hex.hexStringToBytes(sm2SignVOtest.getSm2_sign()));
//        } catch (UnsupportedEncodingException e) {
//
//            e.printStackTrace();
//            return false;
//        }
//       // System.err.println("验签结果--------" +verifys.isVerify());
//        return verifys.isVerify();
//    }
//
//    public static void generateKeyPair(){
//        SM2Factory sm2Factory = SM2Factory.getInstance();
//        AsymmetricCipherKeyPair key = sm2Factory.ecc_key_pair_generator.generateKeyPair();
//        ECPrivateKeyParameters ecpriv = (ECPrivateKeyParameters) key.getPrivate();
//        ECPublicKeyParameters ecpub = (ECPublicKeyParameters) key.getPublic();
//        BigInteger privateKey = ecpriv.getD();
//        ECPoint publicKey = ecpub.getQ();
//        //生成随机秘钥对
//        String prik = "";
//        // 国密规范正式公钥
//        String pubk = "";
//
//        prik=Util.byteToHex(privateKey.toByteArray());
//        pubk=Util.byteToHex(publicKey.getEncoded());
//        System.out.println("公钥: " + pubk);
//        System.out.println("私钥: " + prik);
//    }
//
//    public static void main(String[] args) throws UnsupportedEncodingException {
//        String publicKey = "041D3CE2433116FAC18CAFE91AA5BF418B00F6EB031E12606554B6571A1E197077F3E5ADC954CD708119B8502DE6125073E34A4D0626D1B7ABE7C5F8E725638494";
//        String privateKey = "3A4717A6B65B6BB020E3FECFE2E84BF9CD93D0137DF6B64BB20CD7ADBDB2FEE2";
//        /*String a = QzSm2Utils.decrypt(privateKey, "0416B6927FBB22309D400736C10E6DB5D0DB64020CDC128CF3123909AB34D92AAE8FD769FA13F8E2394A020064F04D7F3630FA88A8D9E06DAD003810283A19AA597DA0066AFDF28FBB5B236E62FD615F012BDBD812A49EEFF6DFED4ED199088BE57936AFACEB86A63A6C6127AB4B59998CE3");
//        System.out.println(a);*/
//     /*   String a = QzSm2Utils.encrypt("04926FD494698637AE6EE30DC4AD141F1962DFA542CACC75F3821C9DFAFB390CF37E7EB0E9220E680F2F066C208AF936DD02128530D0981FA664C350AE273408E2", "{\"tbPolicyDtoList\":[{\"tbInsuranceSchema\":{\"agentCode\":\"\",\"certifyCode\":\"\",\"guaranteeType\":\"2\",\"premium\":\"\",\"tradeCenter\":\"350105\",\"guarantorName\":\"福州AA担保公司\",\"guarantorIdType\":\"0\",\"guarantorIdNo\":\"TB82371604816\"},\"tenderInfo\":{\"approvalNo\":\"永发改审[2018]16号\",\"investProjectCode\":\"T7619164239\",\"tenderProjectCode\":\"X201809520-056\",\"tenderProjectName\":\"泉州市丰泽区甲道路改造\",\"sectionCode\":\"T923171261221\",\"sectionName\":\"泉州市丰泽区甲道路改造-第一标段\",\"contractReckonPrice\":\"120000.00\",\"tenderer\":\"泉州市富足有限公司\",\"tendererCreditCode\":\"91490160481612W\",\"tendererBankCode\":\"SV9116137512\",\"tendererBankOpenBank\":\"中国银行厦门市思明区分行\",\"tendererBankAccount\":\"泉州市富足有限公司\",\"tendererContact\":\"郑富足\",\"tendererContactTel\":\"13669494397\",\"cityCode\":\"350105\",\"tenderProjectType\":\"A01\",\"bidOpenTime\":\"2020-11-11 09:00:00\",\"validPeriod\":\"100\",\"bidBond\":\"120000.00\",\"tenderNoticeUrl\":\"http://220.160.52.164:96/ConstructionInfoPublish/Pages/Home.aspx\",\"tenderFileUrl\":\"http://220.160.52.164:96/ConstructionInfoPublish/Pages/Home.aspx\",\"tenderFileMD5\":\"84516382716347161\"},\"bidde\":{\"bidderName\":\"福州乐市有限公司\",\"bidderCreditCode\":\"91845163827163471\",\"bidderContactName\":\"吴长乐\",\"bidderContactTel\":\"1355942974\",\"bidderContactIdCard\":\"350322199011211904\",\"bidderContactIdcardType\":\"01\",\"bidderAddress\":\"福州市马尾区AA街道\",\"bidderEmail\":\"80551212@qq.com\",\"legalPersonName\":\"郑长乐\",\"legalPersonIdcardType\":\"01\",\"legalPersonIdcard\":\"350322189011211074\",\"legalPersonTel\":\"1366943081\"},\"guaranteeAttachment\":{\"orderUrl\":\"http://114.115.244.226:8082/filemutual/downFilePublic/file.do?file=A410483960-e498f241af915e25135913e528058286\",\"orderUrlMD5\":\"2113129352123174\",\"qualficationFIleUrl\":\"http://114.115.244.226:8082/filemutual/downFilePublic/file.do?file=A410483960-e498f241af915e25135913e528058286\",\"qualficationFIleMD5\":\"5343129352123145\",\"businessLicenseUrl\":\"http://114.115.244.226:8082/filemutual/downFilePublic/file.do?file=A410483960-e498f241af915e25135913e528058286\",\"businessLicenseMD5\":\"8843129352123105\"}}]}");
//        System.out.println(a);*/
//       /* generateKeyPair();
//      String publicKey1="04:98:e2:4b:18:21:7b:b8:95:b4:07:aa:a2:fa:bb:4e:2c:64:70:2a:c5:b7:1c:b5:9b:77:c5:6a:f5:e4:76:89:91:e2:36:1b:3c:bc:1b:80:5f:5b:6f:ee:46:c8:f4:70:20:c6:ed:04:f8:50:75:23:7e:4c:8f:9a:ac:d0:75:10:f5";
//        System.out.println(publicKey1 = publicKey1.replace(":", "").toUpperCase());
//        *//**//*
//
//        System.out.println(QzSm2Utils.encrypt(publicKey1, "中国陆地面积约960万平方千米，东部和南部大陆海岸线1.8万多千米，内海和边海的水域面积约470多万平方千米。"));
//        String aaa ="MIIBGwIBADCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////v////////////////////8AAAAA//////////8wRAQg/////v////////////////////8AAAAA//////////wEICjp+p6dn140TVqeS89lCafzl4n1FauPkt28vUFNlA6TBEEEMsSuLB8ZgRlfmQRGajnJlI/jC7/yZgvhcVpFiTNMdMe8Nzai9PZ3nFm9zuNraSFT0KmHfMYqR0AC3zLlITnwoAIhAP////7///////////////9yA99rIcYFK1O79Ak51UEjAgEBBCcwJQIBAQQg5+Xxqb6y/gH/RStGmwc9tATHf6MuVpTu+VrB4TVnn5s=";
//        System.out.println(Util.hexToByte(aaa));*/
///*
//        String privateKey1="MIIBGwIBADCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////v////////////////////8AAAAA//////////8wRAQg/////v////////////////////8AAAAA//////////wEICjp+p6dn140TVqeS89lCafzl4n1FauPkt28vUFNlA6TBEEEMsSuLB8ZgRlfmQRGajnJlI/jC7/yZgvhcVpFiTNMdMe8Nzai9PZ3nFm9zuNraSFT0KmHfMYqR0AC3zLlITnwoAIhAP////7///////////////9yA99rIcYFK1O79Ak51UEjAgEBBCcwJQIBAQQg5+Xxqb6y/gH/RStGmwc9tATHf6MuVpTu+VrB4TVnn5s=";
//
//
//*/
//
//    String pfx="MIIK3QIBAzCCCpcGCSqGSIb3DQE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dnQiYRyt76+aIBTV672m3o2oCFFTyeasJhb+TSzmDVxnCz5uPtuYHZWkcJHJYEZE5cp6e0OAMHVoeuqVftzrNk5F8KEyXholtgXRkdm6wqjFHwlRCCJvlL7KAUXSPNYNvgLNW1Tqapv3ODBNSH+DUcg3J1UKKbs6SgnIWxG2fBmsdTonwsfJKHQTh5c+OO/+vtsrof+Fa83dHdfsqKQbr/NhELpHFOEbHkbni7VRIKNGm6pQMYB0BO7G6RqngavF5/SlfsjSpUCryWIQdnfstVyhUFg5UvoKGITTNZ5ieSgnqtsg3FDoGnAwzl6NlmwQTZdbJ+v1DQYNRLx+50s4l9pzQ7wexWQptuadPG56ddXETA9MCEwCQYFKw4DAhoFAAQU66ivW3nXbI66/rs4Nl8qkHNGY2cEFKtkzDF+Ykf6NoTtb0cidzeQAlqWAgIEAA==";
//        pfx= new String(Base64.decode(pfx.getBytes()));
//        System.out.println(pfx);
//
//    }
//
//}
